/**
 * @description 工具函数
 * @author cleverstone
 */

export default {
    /**
     * 判断数据类型
     * @param data
     * @param type
     * @return {boolean}
     */
    isType(data, type) {
        type = type.toLowerCase()
        let typeStr = Object.prototype.toString.call(data)
        let define = {
            array: '[object Array]',
            object: '[object Object]',
            null: '[object Null]',
            date: '[object Date]',
            regexp: '[object RegExp]',
            function: '[object Function]',
            string: '[object String]',
            number: '[object Number]',
            boolean: '[object Boolean]',
            undefined: '[object Undefined]',
        }

        if (undefined === define[type]) {
            throw 'Undefined ' + type
        }

        return typeStr === define[type]
    }
}